// pages/url/url.js
var HttpRequest = require("../../http.js"); //HTTP请求request封装
 
Page({

  /**
   * 页面的初始数据
   */
  data: {
      url:'',//招行跳转链接地址 
  },
  getReq: HttpRequest.getReq,//GET数据请求函数
  postReq: HttpRequest.postReq,//POST数据请求
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    const login_Info = JSON.parse(wx.getStorageSync('login_Information')); //登录基础信息
    console.log(wx.getStorageSync('IdCard'));
    const headArray = wx.getStorageSync('UserLogin');
    const token = login_Info.token;
    const userId = login_Info.userId;
    const headmode = {
      'Accept': 'application/json',
      "Content-Type": "application/x-www-form-urlencoded",
      "headMode": headArray,
      "token": token,
    };
    console.log(options.type);
     //健康档案跳转
    if (options.type == 1){
      const url = '/user/v1/toH5?needToken=true&type=reArchives';
      HttpRequest.getReq(url, headmode, function (res, code) {
        //随访高血压ID 
        const ArchivesId = '&followId=' + options.followupId + '&userid=' + wx.getStorageSync('IdCard');
        console.log(res + ArchivesId);
        that.setData({
          url: res + ArchivesId,//地址 
        })
      }) 
    }
     //我的钱包跳转
    else if (options.type == 3){
      that.setData({
        url: 'https://apissl.jkscw.com.cn/bskyH5/Contract/WXCmd.html?token=' + token + '&userId=' + userId + '&appdomain=' + getApp().globalData.wxurl + '',//地址 
      })
    }
     //随访记录（高血压）跳转
    else if (options.type == 21){

      const url = '/user/v1/toH5?needToken=true&type=reGxysf';
      HttpRequest.getReq(url, headmode, function (res, code) { 
        //随访高血压ID 
        const GxyId = '&followId='+options.followupId
        console.log(res + GxyId);
        that.setData({
          url: res + GxyId,//地址 
        })
      })
     
    }
     //随访记录（糖尿病）跳转
    else if (options.type == 22){
      const url = '/user/v1/toH5?needToken=true&type=reTnbsf';
      HttpRequest.getReq(url, headmode, function (res, code) {
        //随访糖尿病ID 
        const TnbId = '&followId=' + options.followupId
        console.log(res + TnbId);
        that.setData({
          url: res + TnbId,//地址 
        })
      })
    }
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})